home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: in2.uu.net!tellab5!news
- From: Joe Toth <toth@tellabs.com>
- Subject: Re: Segmentation fault at return statement. Can't figure out ....
- X-Nntp-Posting-Host: sunh25
- Content-Type: text/plain; charset=us-ascii
- Message-ID: <1996Jan25.140906.6807@tellab5.tellabs.com>
- Sender: news@tellab5.tellabs.com (News)
- Content-Transfer-Encoding: 7bit
- Organization: Tellabs Operations, Inc.
- References: <4dm2n1$egk@murphy.servtech.com> <4dop08$kdi@bcfreenet.seflin.lib.fl.us> <9601201829.AA02117@dxmint.cern.ch> <4e63p2$ljg@bcfreenet.seflin.lib.fl.us> <9601251253.AA14631@dxmint.cern.ch>
- Mime-Version: 1.0
- Date: Thu, 25 Jan 1996 14:09:06 GMT
- X-Mailer: Mozilla 1.1 (X11; U; SunOS 4.1.3 sun4c)
- X-Url: news:9601251253.AA14631@dxmint.cern.ch
-
- Dan Pop <danpop@mail.cern.ch> wrote:
- >z007400b@bcfreenet.seflin.lib.fl.us (Ralph Silverman) writes:
- >
- >>Dan Pop (danpop@mail.cern.ch) wrote:
- >>: z007400b@bcfreenet.seflin.lib.fl.us (Ralph Silverman) writes:
- >>
- >>: > 'test'
- >>: > is likely to be
- >>: > a command of
- >>: > the
- >>: > operating system
- >>
- >>: So what? There's no possible conflict/interaction between a function
- >>: name in a C program and the name of an OS command.
- >>
- >>: > 1) look it up.
- >>: > 2) rename yours.
- >>: ^^^^^^^^^^^^^
- >>: Why???
- >>
- >> is it not possible
- >> that the link order of
- >> test.c etc.
- >> resulted in an executable named
- >> test.exe,
- >> test.com
- >> or such?
- >
- >On some systems, this may be possible, however, on the only system where
- >"test" is a command (that I know of), this is not possible.
- >
- >No matter the name of the resulting executable, this cannot explain the
- >behaviour observed by the original poster.
- >
- >Dan
- >--
- >Dan Pop
- >CERN, CN Division
- >Email: danpop@mail.cern.ch
- >Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-
- Come on guys....
-
- Lets give an answer that helps.
-
-
- On some systems, 'test' is a builtin command of the appropriate
- shell (csh, ksh, etc.). On other systems, it is an executable.
-
- In either case (which together cover all unix & DOS systems), the
- compile/link process doesn't ever look at system/shell commands or
- executables.
-
- The compiler/linker resolve function calls on 'object' files.
-
- If you want to invoke the 'test' executable (if there is one), you
- use a 'C' call something like;
-
- system ( "test <test parameters>" );
-
- This is the only way to execute an executable.
-
- A 'C' function reference to 'test' requires a definition of
- a function named 'test()'. If it is not found in the local source,
- the linker will look for it in the 'object' files (possibly in an
- archive file) specified in the 'link' command.
-
- So, as stated 'There's no possible conflict/interaction<...>'.
-
- Back to the real problem....
-
- The user did not show any of the code that was contained in 'test'
- other than the 'return(999)'. My bet is that the error is in the
- missing code......
-
- Possibly;
- writing outside the bounds of a locally defined array.
- misuse of a pointer.
- any of a number of coding errors.
-
- Something in the code probably wrote over the return pointer.
- IT DOES HAPPEN...................
- It all depends on how & where the return pointers are stored, as
- many systems don't protect the return pointer if it is in the
- local variable heap (or does yours use stacks).
- I've accidentally done it myself.
-
- Without seeing the code, it is impossible to say exactly what
- caused the problem.....
-
- --
- _ _ ___ --------------------------+---------------------------------
- | / _ | Joseph G. Toth Jr. | Tellabs Operations, Inc.
- \_| \_/ | | toth@tellabs.com
-
- > Every program has at least one bug and can be shortened by at least
- > one instruction -- from which, by induction, it is evident that every
- > program can be reduced to one instruction that does not work.
- > -- Ken Arnold
-
-